/*******************************************************************************
 * Copyright (c) 2011 TXT e-solutions SpA
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * This work was performed within the IoT_at_Work Project
 * and partially funded by the European Commission's
 * 7th Framework Programme under the research area ICT-2009.1.3
 * Internet of Things and enterprise environments.
 *
 *
 * Authors:
 *     Cristoforo Seccia (TXT e-solutions SpA)
 *
 * Contributors:
 *      Domenico Rotondi (TXT e-solutions SpA)
 *******************************************************************************/
package it.txt.access.capability.demo.server.view;

import it.txt.access.capability.commons.filter.FilterJKS;
import it.txt.access.capability.commons.signer.model.X509DocumentSignerInfo;
import it.txt.access.capability.demo.server.util.Resources;
import it.txt.access.capability.demo.server.view.model.ServiceRequestInfoModel;
import it.txt.access.capability.demo.server.view.model.ServerResponseInfoModel;
import java.awt.event.WindowEvent;
import java.io.File;
import java.net.URL;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JLabel;

/**
 *
 * @author Cristoforo Seccia (TXT e-solutions SpA)
 */
public class ServerGUI extends javax.swing.JFrame{

    private static final URL APP_LOGO = ServerGUI.class.getResource(Resources.IMAGES_DIR + "IoT_icon.png");
    private static final String APP_TITLE = "IoT@Work - Capability Base Authorization Demo Server";
    private ServerGUIController serverGUIController;
    public static final int FINISH_RETURN_CODE = 0;
    public static final int CANCEL_RETURN_CODE = 1;
    public static final int ERROR_RETURN_CODE = -1;
    public static final int UNDEF_RETURN_CODE = 2;
    private int returnCode = UNDEF_RETURN_CODE;
    //The keystore file chooser
    private JFileChooser keystoreChooser;
    //The keystore file filter
    private FilterJKS filterKeystore;
    //The cyrrent keystore dir
    private File currentKeystoreFile;

    private AboutDialog aboutDialog;

    public static Icon ICON_SETTINGS;
    public static Icon ICON_ERROR;
    public static Icon ICON_OK;
    
    /** Creates new form ServerGUI */
    protected ServerGUI(ServerGUIController sguic) {
        initComponents();
        setTitle(APP_TITLE);
        serverGUIController = sguic;
        setIconImage(new ImageIcon(APP_LOGO).getImage());
        filterKeystore = new FilterJKS();
        keystoreChooser = new JFileChooser();
        keystoreChooser.setFileFilter(filterKeystore);
        keystoreChooser.setMultiSelectionEnabled(false);
    }

    //When a request from the client is received
    protected void validateRequestDataForm(ServiceRequestInfoModel model){
        requestCapabilityIDText.setText(model.getCapabilityID());
        requestRequestIDtext.setText(model.getRequestID());
        requestRequestSignerText.setText(model.getSigner());
        requestRequestedOperationText.setText(model.getOperation());
        requestResourceIDText.setText(model.getResourceID());
        requestSignerKeyIDText.setText(model.getSignerKeyID());
        requestSignerKeyIssuerText.setText(model.getSignerKeyIssuer());        
    }

    //When a response to the client is sent
    protected void validateResponseDataForm(ServerResponseInfoModel model){
        responseInfoResponseIDText.setText(model.getResponseID());
        serviceResponseStatusArea.setText(model.getResponseStatus());
        serviceResponseStatusArea.setLineWrap(true);
        serviceResponseStatusArea.validate();
    }

    //Clear the request received from the client.
    private void invalidateRequestDataForm(){
        requestCapabilityIDText.setText("");
        requestRequestIDtext.setText("");
        requestRequestSignerText.setText("");
        requestRequestedOperationText.setText("");
        requestResourceIDText.setText("");
        requestSignerKeyIDText.setText("");
        requestSignerKeyIssuerText.setText("");
        responseInfoResponseIDText.setText("");
        serviceResponseStatusArea.setText("");
        serviceResponseStatusArea.validate();
        serverGUIController.resetClientProgressState();
    }
    
    //recover the server keystore file
    private void recoverServerKeystoreFile(){
        if(currentKeystoreFile == null){
            keystoreChooser.setCurrentDirectory(new File("."));
        }
        else{
            keystoreChooser.setCurrentDirectory(currentKeystoreFile);
        }
        int returnValue = keystoreChooser.showOpenDialog(this);
        if (returnValue == JFileChooser.APPROVE_OPTION) {
            currentKeystoreFile = keystoreChooser.getSelectedFile();
            keystoreText.setText(currentKeystoreFile.getPath());
            keystoreText.setCaretPosition(0);
            serverCertificateSetButton.setEnabled(true);
        }
    }

    //Recover the the server keystore values
    private void recoverServerKeystoreValues(){
        X509DocumentSignerInfo signerInfo = new X509DocumentSignerInfo();
        signerInfo.setSignerID(serverIdentityText.getText());
        signerInfo.setKeystorePath(keystoreText.getText());
        signerInfo.setKeystorePwd(keystorePasswordText.getPassword());
        signerInfo.setPrivateKeyPwd(privateKeyPasswordText.getPassword());
        signerInfo.setKeystorePath(currentKeystoreFile.getAbsolutePath());
        serverGUIController.setServerKeystoreData(signerInfo);
    }

    //Clear the server keystore data form
    private void invalidateServerKeystoreDataForm(){
        serverIdentityText.setText("");
        keystoreText.setText("");
        keystorePasswordText.setText("");
        privateKeyPasswordText.setText("");
        serverCertificateSetButton.setEnabled(false);        
    }

    //Clear the tcp port text box and its value
    private void invalidateServerTCPConnectionForm(){
        serverPortText.setText("");
        serverPortText.setValue(null);
    }
    
    //Append log messages
    protected void appendLogMessage(String msg) {
        logTextArea.append(msg);
    }

    //Recover the progress state labels
    protected JLabel getProgressRequestReadyLabel(){
        return progressRequestReadyLabel;
    }

    protected JLabel getProgressTCPConnectionLabel(){
        return progressTCPConnEnstabLabel;
    }

    protected JLabel getProgressServiceRequestReceivedLabel(){
        return progressRequestReceivedLabel;
    }

    protected JLabel getProgressServiceResponseSentLabel(){
        return progressServiceResponseSentLabel;
    }

    //Showing status on the status bar
    protected void changeStatusLabelText(String value){
        bottomStatusValueLabel.setText(value);
    }

    //Recover the server return code
    protected int getReturnCode() {
        return returnCode;
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        battomStatusPanel = new javax.swing.JPanel();
        bottomStatusLabel = new javax.swing.JLabel();
        bottomStatusValueLabel = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        manageServerPanel = new javax.swing.JPanel();
        serverButtonsPanel = new javax.swing.JPanel();
        serverStopButton = new javax.swing.JButton();
        serverStartButton = new javax.swing.JButton();
        responseProgressPanel = new javax.swing.JPanel();
        progressRequestReadyLabel = new javax.swing.JLabel();
        progressTCPConnEnstabLabel = new javax.swing.JLabel();
        progressRequestReceivedLabel = new javax.swing.JLabel();
        progressServiceResponseSentLabel = new javax.swing.JLabel();
        requestDataPanel = new javax.swing.JPanel();
        requestRequestIDLabel = new javax.swing.JLabel();
        requestRequestIDtext = new javax.swing.JTextField();
        requestCapabilityIDLabel = new javax.swing.JLabel();
        requestCapabilityIDText = new javax.swing.JTextField();
        requestRequestedOperationLabel = new javax.swing.JLabel();
        requestRequestedOperationText = new javax.swing.JTextField();
        requestResourceIDLabel = new javax.swing.JLabel();
        requestResourceIDText = new javax.swing.JTextField();
        requestRequestSignerLabel = new javax.swing.JLabel();
        requestRequestSignerText = new javax.swing.JTextField();
        requestSignerKeyIDLabel = new javax.swing.JLabel();
        requestSignerKeyIDText = new javax.swing.JTextField();
        requestSignerKeyIssuerLabel = new javax.swing.JLabel();
        requestSignerKeyIssuerText = new javax.swing.JTextField();
        responseInformationPanel = new javax.swing.JPanel();
        responseInfoResponseIDLabel = new javax.swing.JLabel();
        responseInfoResponseIDText = new javax.swing.JTextField();
        responseInfoServiceResponseStatusLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        serviceResponseStatusArea = new javax.swing.JTextArea();
        responseButtonsPanel = new javax.swing.JPanel();
        clearRequestDataButton = new javax.swing.JButton();
        configParamsPanel = new javax.swing.JPanel();
        serverIDDataSectionPanel = new javax.swing.JPanel();
        serverIdentityLabel = new javax.swing.JLabel();
        keystoreLabel = new javax.swing.JLabel();
        keystorePasswordLabel = new javax.swing.JLabel();
        privateKeyPasswordLabel = new javax.swing.JLabel();
        serverIdentityText = new javax.swing.JTextField();
        keystoreText = new javax.swing.JTextField();
        privateKeyPasswordText = new javax.swing.JPasswordField();
        keystorePasswordText = new javax.swing.JPasswordField();
        keystoreButton = new javax.swing.JButton();
        serverCertificateClearButton = new javax.swing.JButton();
        serverCertificateSetButton = new javax.swing.JButton();
        parametersConnectionPanel = new javax.swing.JPanel();
        serverPortLabel = new javax.swing.JLabel();
        serverConnectionClearButton = new javax.swing.JButton();
        serverTCPPortButton = new javax.swing.JButton();
        serverPortText = new javax.swing.JFormattedTextField();
        serverLogPanel = new javax.swing.JPanel();
        logTextAreaPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        logTextArea = new javax.swing.JTextArea();
        logClearButtonPanel = new javax.swing.JPanel();
        clerLogButton = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        exitMenuItem = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        aboutMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        battomStatusPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        bottomStatusLabel.setText("Status: ");

        javax.swing.GroupLayout battomStatusPanelLayout = new javax.swing.GroupLayout(battomStatusPanel);
        battomStatusPanel.setLayout(battomStatusPanelLayout);
        battomStatusPanelLayout.setHorizontalGroup(
            battomStatusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, battomStatusPanelLayout.createSequentialGroup()
                .addContainerGap(537, Short.MAX_VALUE)
                .addComponent(bottomStatusLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bottomStatusValueLabel)
                .addContainerGap())
        );
        battomStatusPanelLayout.setVerticalGroup(
            battomStatusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, battomStatusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(bottomStatusLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                .addComponent(bottomStatusValueLabel))
        );

        serverButtonsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Commands"));

        serverStopButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Stop_16x16.png"))); // NOI18N
        serverStopButton.setText("Stop Listening");
        serverStopButton.setEnabled(false);
        serverStopButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverStopButtonActionPerformed(evt);
            }
        });

        serverStartButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Play_16x16.png"))); // NOI18N
        serverStartButton.setText("Start Listening");
        serverStartButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverStartButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout serverButtonsPanelLayout = new javax.swing.GroupLayout(serverButtonsPanel);
        serverButtonsPanel.setLayout(serverButtonsPanelLayout);
        serverButtonsPanelLayout.setHorizontalGroup(
            serverButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serverButtonsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(serverStartButton)
                .addGap(18, 18, 18)
                .addComponent(serverStopButton)
                .addContainerGap(288, Short.MAX_VALUE))
        );
        serverButtonsPanelLayout.setVerticalGroup(
            serverButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serverButtonsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(serverButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(serverStartButton)
                    .addComponent(serverStopButton))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        responseProgressPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Server Activity Monitor"));

        progressRequestReadyLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Settings_16x16.png"))); // NOI18N
        progressRequestReadyLabel.setText("Ready to accept Requeste");
        progressRequestReadyLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        progressRequestReadyLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        progressRequestReadyLabel.setIconTextGap(10);
        progressRequestReadyLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        responseProgressPanel.add(progressRequestReadyLabel);

        progressTCPConnEnstabLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Settings_16x16.png"))); // NOI18N
        progressTCPConnEnstabLabel.setText("TCP Connection Enstablished");
        progressTCPConnEnstabLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        progressTCPConnEnstabLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        progressTCPConnEnstabLabel.setIconTextGap(10);
        progressTCPConnEnstabLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        responseProgressPanel.add(progressTCPConnEnstabLabel);

        progressRequestReceivedLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Settings_16x16.png"))); // NOI18N
        progressRequestReceivedLabel.setText("Service Request Received");
        progressRequestReceivedLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        progressRequestReceivedLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        progressRequestReceivedLabel.setIconTextGap(10);
        progressRequestReceivedLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        responseProgressPanel.add(progressRequestReceivedLabel);

        progressServiceResponseSentLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Settings_16x16.png"))); // NOI18N
        progressServiceResponseSentLabel.setText("Service Response Sent");
        progressServiceResponseSentLabel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        progressServiceResponseSentLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        progressServiceResponseSentLabel.setIconTextGap(10);
        progressServiceResponseSentLabel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        responseProgressPanel.add(progressServiceResponseSentLabel);

        requestDataPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Request Data"));

        requestRequestIDLabel.setText("Request ID");

        requestRequestIDtext.setEditable(false);

        requestCapabilityIDLabel.setText("Capability ID");

        requestCapabilityIDText.setEditable(false);

        requestRequestedOperationLabel.setText("Requested Operation");

        requestRequestedOperationText.setEditable(false);

        requestResourceIDLabel.setText("Resource ID");

        requestResourceIDText.setEditable(false);

        requestRequestSignerLabel.setText("Request Signer");

        requestRequestSignerText.setEditable(false);

        requestSignerKeyIDLabel.setText("Signer Key ID");

        requestSignerKeyIDText.setEditable(false);

        requestSignerKeyIssuerLabel.setText("Signer Key Issuer");

        requestSignerKeyIssuerText.setEditable(false);

        javax.swing.GroupLayout requestDataPanelLayout = new javax.swing.GroupLayout(requestDataPanel);
        requestDataPanel.setLayout(requestDataPanelLayout);
        requestDataPanelLayout.setHorizontalGroup(
            requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestDataPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(requestRequestIDLabel)
                    .addGroup(requestDataPanelLayout.createSequentialGroup()
                        .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(requestResourceIDLabel)
                            .addComponent(requestRequestedOperationLabel)
                            .addComponent(requestRequestSignerLabel)
                            .addComponent(requestSignerKeyIDLabel)
                            .addComponent(requestSignerKeyIssuerLabel)
                            .addComponent(requestCapabilityIDLabel))
                        .addGap(18, 18, 18)
                        .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(requestCapabilityIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                            .addComponent(requestSignerKeyIssuerText, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                            .addComponent(requestSignerKeyIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                            .addComponent(requestRequestSignerText, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                            .addComponent(requestRequestedOperationText, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                            .addComponent(requestResourceIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE)
                            .addComponent(requestRequestIDtext, javax.swing.GroupLayout.DEFAULT_SIZE, 415, Short.MAX_VALUE))))
                .addContainerGap())
        );
        requestDataPanelLayout.setVerticalGroup(
            requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(requestDataPanelLayout.createSequentialGroup()
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(requestRequestIDLabel)
                    .addComponent(requestRequestIDtext, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(requestResourceIDLabel)
                    .addComponent(requestResourceIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(requestRequestedOperationLabel)
                    .addComponent(requestRequestedOperationText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(requestRequestSignerLabel)
                    .addComponent(requestRequestSignerText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(requestSignerKeyIDLabel)
                    .addComponent(requestSignerKeyIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(requestSignerKeyIssuerLabel)
                    .addComponent(requestSignerKeyIssuerText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(requestDataPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(requestCapabilityIDLabel)
                    .addComponent(requestCapabilityIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        responseInformationPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Response Information"));

        responseInfoResponseIDLabel.setText("Response ID");

        responseInfoResponseIDText.setEditable(false);

        responseInfoServiceResponseStatusLabel.setText("Service Response Status");

        serviceResponseStatusArea.setColumns(20);
        serviceResponseStatusArea.setEditable(false);
        serviceResponseStatusArea.setRows(5);
        jScrollPane2.setViewportView(serviceResponseStatusArea);

        javax.swing.GroupLayout responseInformationPanelLayout = new javax.swing.GroupLayout(responseInformationPanel);
        responseInformationPanel.setLayout(responseInformationPanelLayout);
        responseInformationPanelLayout.setHorizontalGroup(
            responseInformationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(responseInformationPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(responseInformationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(responseInfoResponseIDLabel)
                    .addComponent(responseInfoServiceResponseStatusLabel))
                .addGap(18, 18, 18)
                .addGroup(responseInformationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)
                    .addComponent(responseInfoResponseIDText, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE))
                .addContainerGap())
        );
        responseInformationPanelLayout.setVerticalGroup(
            responseInformationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(responseInformationPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(responseInformationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(responseInfoResponseIDLabel)
                    .addComponent(responseInfoResponseIDText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(responseInformationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(responseInfoServiceResponseStatusLabel)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE))
                .addContainerGap())
        );

        responseButtonsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        clearRequestDataButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        clearRequestDataButton.setText("Clear");
        clearRequestDataButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearRequestDataButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout responseButtonsPanelLayout = new javax.swing.GroupLayout(responseButtonsPanel);
        responseButtonsPanel.setLayout(responseButtonsPanelLayout);
        responseButtonsPanelLayout.setHorizontalGroup(
            responseButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, responseButtonsPanelLayout.createSequentialGroup()
                .addContainerGap(469, Short.MAX_VALUE)
                .addComponent(clearRequestDataButton)
                .addContainerGap())
        );
        responseButtonsPanelLayout.setVerticalGroup(
            responseButtonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, responseButtonsPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(clearRequestDataButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout manageServerPanelLayout = new javax.swing.GroupLayout(manageServerPanel);
        manageServerPanel.setLayout(manageServerPanelLayout);
        manageServerPanelLayout.setHorizontalGroup(
            manageServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, manageServerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(manageServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(responseInformationPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(requestDataPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(serverButtonsPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(responseProgressPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 572, Short.MAX_VALUE)
                    .addComponent(responseButtonsPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        manageServerPanelLayout.setVerticalGroup(
            manageServerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(manageServerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(serverButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(responseProgressPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(requestDataPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(responseInformationPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(responseButtonsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Manage Server", new javax.swing.ImageIcon(getClass().getResource("/images/icons_24x24/Globe_24x24.png")), manageServerPanel); // NOI18N

        serverIDDataSectionPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Server ID Data Section"));

        serverIdentityLabel.setText("Server Identity");

        keystoreLabel.setText("Keystore");

        keystorePasswordLabel.setText("Keystore Password");

        privateKeyPasswordLabel.setText("Private Key Password");

        keystoreButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Open_16x16.png"))); // NOI18N
        keystoreButton.setText("Open");
        keystoreButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keystoreButtonActionPerformed(evt);
            }
        });

        serverCertificateClearButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        serverCertificateClearButton.setText("Clear");
        serverCertificateClearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverCertificateClearButtonActionPerformed(evt);
            }
        });

        serverCertificateSetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Check_16x16.png"))); // NOI18N
        serverCertificateSetButton.setText("Set");
        serverCertificateSetButton.setEnabled(false);
        serverCertificateSetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverCertificateSetButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout serverIDDataSectionPanelLayout = new javax.swing.GroupLayout(serverIDDataSectionPanel);
        serverIDDataSectionPanel.setLayout(serverIDDataSectionPanelLayout);
        serverIDDataSectionPanelLayout.setHorizontalGroup(
            serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serverIDDataSectionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(serverIDDataSectionPanelLayout.createSequentialGroup()
                        .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(privateKeyPasswordLabel)
                            .addComponent(keystorePasswordLabel)
                            .addComponent(serverIdentityLabel)
                            .addComponent(keystoreLabel))
                        .addGap(18, 18, 18)
                        .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, serverIDDataSectionPanelLayout.createSequentialGroup()
                                .addComponent(keystoreText, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(keystoreButton))
                            .addComponent(serverIdentityText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
                            .addComponent(privateKeyPasswordText, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)
                            .addComponent(keystorePasswordText, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, serverIDDataSectionPanelLayout.createSequentialGroup()
                        .addComponent(serverCertificateSetButton)
                        .addGap(18, 18, 18)
                        .addComponent(serverCertificateClearButton)))
                .addContainerGap())
        );
        serverIDDataSectionPanelLayout.setVerticalGroup(
            serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serverIDDataSectionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(keystoreLabel)
                    .addComponent(keystoreText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(keystoreButton))
                .addGap(18, 18, 18)
                .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(serverIdentityLabel)
                    .addComponent(serverIdentityText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(keystorePasswordLabel)
                    .addComponent(keystorePasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(privateKeyPasswordLabel)
                    .addComponent(privateKeyPasswordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(serverIDDataSectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(serverCertificateClearButton)
                    .addComponent(serverCertificateSetButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        parametersConnectionPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Server Connection Parameters"));

        serverPortLabel.setText("Server TCP Port");

        serverConnectionClearButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        serverConnectionClearButton.setText("Clear");
        serverConnectionClearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverConnectionClearButtonActionPerformed(evt);
            }
        });

        serverTCPPortButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Check_16x16.png"))); // NOI18N
        serverTCPPortButton.setText("Set");
        serverTCPPortButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                serverTCPPortButtonActionPerformed(evt);
            }
        });

        serverPortText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#"))));

        javax.swing.GroupLayout parametersConnectionPanelLayout = new javax.swing.GroupLayout(parametersConnectionPanel);
        parametersConnectionPanel.setLayout(parametersConnectionPanelLayout);
        parametersConnectionPanelLayout.setHorizontalGroup(
            parametersConnectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(parametersConnectionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(parametersConnectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(parametersConnectionPanelLayout.createSequentialGroup()
                        .addComponent(serverPortLabel)
                        .addGap(18, 18, 18)
                        .addComponent(serverPortText, javax.swing.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, parametersConnectionPanelLayout.createSequentialGroup()
                        .addComponent(serverTCPPortButton)
                        .addGap(18, 18, 18)
                        .addComponent(serverConnectionClearButton)))
                .addContainerGap())
        );
        parametersConnectionPanelLayout.setVerticalGroup(
            parametersConnectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(parametersConnectionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(parametersConnectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(serverPortLabel)
                    .addComponent(serverPortText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 284, Short.MAX_VALUE)
                .addGroup(parametersConnectionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(serverConnectionClearButton)
                    .addComponent(serverTCPPortButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout configParamsPanelLayout = new javax.swing.GroupLayout(configParamsPanel);
        configParamsPanel.setLayout(configParamsPanelLayout);
        configParamsPanelLayout.setHorizontalGroup(
            configParamsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, configParamsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(configParamsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(parametersConnectionPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(serverIDDataSectionPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        configParamsPanelLayout.setVerticalGroup(
            configParamsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(configParamsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(serverIDDataSectionPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(parametersConnectionPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Configuration Parameters", new javax.swing.ImageIcon(getClass().getResource("/images/icons_24x24/Properties_24x24.png")), configParamsPanel); // NOI18N

        logTextAreaPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Capability Based Authorization - Events Log"));

        logTextArea.setColumns(20);
        logTextArea.setEditable(false);
        logTextArea.setRows(5);
        jScrollPane1.setViewportView(logTextArea);

        logClearButtonPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        clerLogButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Remove_16x16.png"))); // NOI18N
        clerLogButton.setText("Clear");
        clerLogButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clerLogButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout logClearButtonPanelLayout = new javax.swing.GroupLayout(logClearButtonPanel);
        logClearButtonPanel.setLayout(logClearButtonPanelLayout);
        logClearButtonPanelLayout.setHorizontalGroup(
            logClearButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logClearButtonPanelLayout.createSequentialGroup()
                .addContainerGap(445, Short.MAX_VALUE)
                .addComponent(clerLogButton)
                .addContainerGap())
        );
        logClearButtonPanelLayout.setVerticalGroup(
            logClearButtonPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logClearButtonPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(clerLogButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout logTextAreaPanelLayout = new javax.swing.GroupLayout(logTextAreaPanel);
        logTextAreaPanel.setLayout(logTextAreaPanelLayout);
        logTextAreaPanelLayout.setHorizontalGroup(
            logTextAreaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logTextAreaPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(logTextAreaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
                    .addComponent(logClearButtonPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        logTextAreaPanelLayout.setVerticalGroup(
            logTextAreaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, logTextAreaPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 512, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(logClearButtonPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout serverLogPanelLayout = new javax.swing.GroupLayout(serverLogPanel);
        serverLogPanel.setLayout(serverLogPanelLayout);
        serverLogPanelLayout.setHorizontalGroup(
            serverLogPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serverLogPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logTextAreaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        serverLogPanelLayout.setVerticalGroup(
            serverLogPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(serverLogPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(logTextAreaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("View Log", new javax.swing.ImageIcon(getClass().getResource("/images/icons_24x24/Text Document_24x24.png")), serverLogPanel); // NOI18N

        fileMenu.setText("File");

        exitMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Log Out_16x16.png"))); // NOI18N
        exitMenuItem.setText("Exit");
        exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitMenuItemActionPerformed(evt);
            }
        });
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText("Help");

        aboutMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons_16x16/Information_16x16.png"))); // NOI18N
        aboutMenuItem.setText("About");
        aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutMenuItemActionPerformed(evt);
            }
        });
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
                    .addComponent(battomStatusPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 686, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(battomStatusPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
        close(FINISH_RETURN_CODE);
    }//GEN-LAST:event_exitMenuItemActionPerformed

    private void serverStartButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverStartButtonActionPerformed
        if(serverGUIController.startServerListening()){
            serverStartButton.setEnabled(false);
            serverStopButton.setEnabled(true);
        }
    }//GEN-LAST:event_serverStartButtonActionPerformed

    private void serverStopButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverStopButtonActionPerformed
        serverGUIController.stopServerListening();
        serverStartButton.setEnabled(true);
        serverStopButton.setEnabled(false);
    }//GEN-LAST:event_serverStopButtonActionPerformed

    private void clearRequestDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearRequestDataButtonActionPerformed
        invalidateRequestDataForm();
    }//GEN-LAST:event_clearRequestDataButtonActionPerformed

    private void keystoreButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_keystoreButtonActionPerformed
        recoverServerKeystoreFile();
    }//GEN-LAST:event_keystoreButtonActionPerformed

    private void serverCertificateSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverCertificateSetButtonActionPerformed
        recoverServerKeystoreValues();
    }//GEN-LAST:event_serverCertificateSetButtonActionPerformed

    private void serverCertificateClearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverCertificateClearButtonActionPerformed
        invalidateServerKeystoreDataForm();
    }//GEN-LAST:event_serverCertificateClearButtonActionPerformed

    private void serverTCPPortButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverTCPPortButtonActionPerformed
        if (serverPortText.getValue() != null) {
            serverGUIController.setServerConnectionParams((Long) serverPortText.getValue());
        }
    }//GEN-LAST:event_serverTCPPortButtonActionPerformed

    private void serverConnectionClearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serverConnectionClearButtonActionPerformed
        invalidateServerTCPConnectionForm();
    }//GEN-LAST:event_serverConnectionClearButtonActionPerformed

    private void clerLogButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clerLogButtonActionPerformed
        logTextArea.setText("");
    }//GEN-LAST:event_clerLogButtonActionPerformed

    private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
        if(aboutDialog == null){
            aboutDialog = new AboutDialog(this,false);
        }
        aboutDialog.setVisible(true);
    }//GEN-LAST:event_aboutMenuItemActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutMenuItem;
    private javax.swing.JPanel battomStatusPanel;
    private javax.swing.JLabel bottomStatusLabel;
    private javax.swing.JLabel bottomStatusValueLabel;
    private javax.swing.JButton clearRequestDataButton;
    private javax.swing.JButton clerLogButton;
    private javax.swing.JPanel configParamsPanel;
    private javax.swing.JMenuItem exitMenuItem;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton keystoreButton;
    private javax.swing.JLabel keystoreLabel;
    private javax.swing.JLabel keystorePasswordLabel;
    private javax.swing.JPasswordField keystorePasswordText;
    private javax.swing.JTextField keystoreText;
    private javax.swing.JPanel logClearButtonPanel;
    private javax.swing.JTextArea logTextArea;
    private javax.swing.JPanel logTextAreaPanel;
    private javax.swing.JPanel manageServerPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JPanel parametersConnectionPanel;
    private javax.swing.JLabel privateKeyPasswordLabel;
    private javax.swing.JPasswordField privateKeyPasswordText;
    private javax.swing.JLabel progressRequestReadyLabel;
    private javax.swing.JLabel progressRequestReceivedLabel;
    private javax.swing.JLabel progressServiceResponseSentLabel;
    private javax.swing.JLabel progressTCPConnEnstabLabel;
    private javax.swing.JLabel requestCapabilityIDLabel;
    private javax.swing.JTextField requestCapabilityIDText;
    private javax.swing.JPanel requestDataPanel;
    private javax.swing.JLabel requestRequestIDLabel;
    private javax.swing.JTextField requestRequestIDtext;
    private javax.swing.JLabel requestRequestSignerLabel;
    private javax.swing.JTextField requestRequestSignerText;
    private javax.swing.JLabel requestRequestedOperationLabel;
    private javax.swing.JTextField requestRequestedOperationText;
    private javax.swing.JLabel requestResourceIDLabel;
    private javax.swing.JTextField requestResourceIDText;
    private javax.swing.JLabel requestSignerKeyIDLabel;
    private javax.swing.JTextField requestSignerKeyIDText;
    private javax.swing.JLabel requestSignerKeyIssuerLabel;
    private javax.swing.JTextField requestSignerKeyIssuerText;
    private javax.swing.JPanel responseButtonsPanel;
    private javax.swing.JLabel responseInfoResponseIDLabel;
    private javax.swing.JTextField responseInfoResponseIDText;
    private javax.swing.JLabel responseInfoServiceResponseStatusLabel;
    private javax.swing.JPanel responseInformationPanel;
    private javax.swing.JPanel responseProgressPanel;
    private javax.swing.JPanel serverButtonsPanel;
    private javax.swing.JButton serverCertificateClearButton;
    private javax.swing.JButton serverCertificateSetButton;
    private javax.swing.JButton serverConnectionClearButton;
    private javax.swing.JPanel serverIDDataSectionPanel;
    private javax.swing.JLabel serverIdentityLabel;
    private javax.swing.JTextField serverIdentityText;
    private javax.swing.JPanel serverLogPanel;
    private javax.swing.JLabel serverPortLabel;
    private javax.swing.JFormattedTextField serverPortText;
    private javax.swing.JButton serverStartButton;
    private javax.swing.JButton serverStopButton;
    private javax.swing.JButton serverTCPPortButton;
    private javax.swing.JTextArea serviceResponseStatusArea;
    // End of variables declaration//GEN-END:variables

    private void close(int code) {
        returnCode = code;
        dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }

    //Static section
    static {
        ICON_SETTINGS =
                new javax.swing.ImageIcon(ServerGUI.class.getResource("/images/icons_16x16/Settings_16x16.png"));
        ICON_OK =
                new javax.swing.ImageIcon(ServerGUI.class.getResource("/images/icons_16x16/Check_16x16.png"));
        ICON_ERROR =
                new javax.swing.ImageIcon(ServerGUI.class.getResource("/images/icons_16x16/Cancel_16x16.png"));
    }
}
